
<html>
<head>
	<title>Thanks for contact us.</title>
</head>
<body>
<center>
<br>
<?php 
//Rquire MySqlAdapter.
require_once(dirname(__FILE__).'/../db/MySqlAdapter.php');

//echo "<br>Step 1: open a connection to the DB<br>";
$conn = MySqlAdapter::connect1();

if (isset($_REQUEST['cuname']) && isset($_REQUEST['cueml']) && isset($_REQUEST['cumsg']))
{
	if (($_REQUEST['cueml']) && ($_REQUEST['cuname']) && ($_REQUEST['cumsg']))
	{
		//sending all the details to the system admin by email:
		$msgbody = "sender_email:\t".$_REQUEST['cueml']."\nsender_name:\t".$_REQUEST['cuname']."\ncontent_body:\n".$_REQUEST['cumsg'];		
		mail("dudi.email@gmail.com", "Ohel_Shelomo_website: New contact-us msg was added", $msgbody, "From: <ADMIN@Ohel.shelomo.COM>");
		if ($conn):
			$result = MySqlAdapter::connect2();
		else:
			die ("Could not connect to db " . mysql_error());
		endif;

		//echo "<br>Step 5: Insert rows into the books table<br>";
		$query = "insert into contactus values (CURRENT_TIMESTAMP,'".$_REQUEST['cuname']."','".$_REQUEST['cueml']."','".$_REQUEST['cumsg']."');"; 	
		mysql_query($query)   or die ("Invalid insert " . mysql_error());

		/* script for droping the all DataBase: `ohel_shelomo_2012`.
		$query = "DROP DATABASE `ohel_shelomo_2012`";
		mysql_query($query)   or die ("Invalid insert " . mysql_error());
		echo "DROPED DATABASE `ohel_shelomo_2012`";
		*/
		
		print("Thanks !<br>\n\tYour massege was successfully sent.");
		//echo $_REQUEST['cuemail'];
		//echo $_REQUEST['sendername'];
		//echo $_REQUEST['cumsg'];
	}
	else
		{ echo "Please fill all the 3 fileds.";}
}
	else
		{ echo "Please fill all the 3 fileds. Or enter this page in the acceptable way";}
?>
<br/>
<A HREF="javascript:history.back()">Back</A>
<?php
mysql_close($conn);
?>
</center>
</body>
</html>